package main;

public class XYCoordinate implements ICoordinate {

	public XYCoordinate(int x, int y) {
		positionX = x;
		positionY = y;
	}
	
	public XYCoordinate(XYCoordinate xy) {
		positionX = xy.positionX;
		positionY = xy.positionY;
	}
	
	public String printPosition() {
		return new String("(" + new Integer(positionX).toString() +
				", " + new Integer(positionY).toString());
	}
	
	
	public ICoordinate getNeighbor(int direction) {
		switch(direction) {
		case ICoordinate.DIR_BOTTOM:
			return new XYCoordinate(positionX, positionY+1);
		case ICoordinate.DIR_LEFT:
			return new XYCoordinate(positionX-1, positionY);
		case ICoordinate.DIR_RIGHT:
			return new XYCoordinate(positionX+1, positionY);
		case ICoordinate.DIR_TOP:
			return new XYCoordinate(positionX, positionY-1);
		default:
			return null;
		}
	}

	/**
	 * Gets the X value of this coordinate
	 * @return int
	 */
	public int getPositionX() {
		return positionX;
	}
	
	/**
	 * Gets the Y value of this coordinate
	 * @return int
	 */
	public int getPositionY() {
		return positionY;
	}

	/* Private */
	protected int positionX;
	protected int positionY;

}